package cn.b504.qpcr.entity.data;

import java.util.List;

/**
 * 用于处理从通讯库接收的 pcr 数据
 *
 * @author ssc
 * @create 2020-08-23
 */
public class PcrData {
  public static final short POSITION_NUMBER = 96;

  private final short cycle;
  private final short channel;
  private final short stepNumber;
  private final float[] data = new float[POSITION_NUMBER];

  private PcrData(short cycle, short channel, short stepNumber) {
    this.cycle = cycle;
    this.channel = channel;
    this.stepNumber = stepNumber;
  }

  public float[] getData() {
    return data;
  }

  public static PcrData getInstance(List<PcrData> pcrDataList, short cycle, short channel, short stepNumber) {
    for (PcrData pcrData : pcrDataList) {
      if (pcrData.cycle == cycle && pcrData.channel == channel && pcrData.stepNumber == stepNumber) {
        return pcrData;
      }
    }
    PcrData pcrData = new PcrData(cycle, channel, stepNumber);
    pcrDataList.add(pcrData);
    return pcrData;
  }
}
